library(dplyr)
library(tidyr)
library(foreign)

# 2000-2004 Merged File ANES has too many variables to be opened in Stata
# This code selects the variables needed for the analysis
# 	and saves them in a new dataset "anes_timeseries_2012_slim.dta" 

panel<-read.dta("*/Replication files/anes_mergedfile_2000to2004.dta")



panel_alt <- select(panel, M001511,M001508,M001510,M001509,M001651,M025179,M045154,M045049a,M045193,M045058x,M023149, M023150, M001029, M000913,M000446, M001367, M045091x , M045049 ,M023039, M023040, M023124,# M023124x, 
M023125, #M023125x, 
M023115, M023113, M045004,M045180x,M001249, M000401, M023028, M023022, M023038X, M000523)

write.dta(panel_alt, "*/Replication files/panel_slim.dta")